<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="/">
  <html>
  <body>
  <h2>IMDb Things</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Name</th>
      <th>Leading Actor</th>
      <th>Directed</th>
      <th>Acted In</th>
    </tr>
    <xsl:for-each select="IMDb/Thing">
    <xsl:if test="local-name(child::*[1])='Person'">
	    <tr>
	      <td><xsl:value-of select="Person/Name"/></td>
	      <td>Not Aplicable</td>
	      <td><xsl:value-of select="Person/Filmography/Directing/Movie[1]/@name"/></td>
	      <td><xsl:value-of select="Person/Filmography/Acting/Movie[1]/@name"/></td>
	    </tr>
    </xsl:if>
    <xsl:if test="local-name(child::*[1])='Title'">
	    <tr>
	      <td><xsl:value-of select="Title/Name"/></td>
	      <td><xsl:value-of select="Title/Cast/Leading/Actor/@name"/></td>
	      <td>Not Aplicable</td>
	      <td>Not Aplicable</td>
	    </tr>
    </xsl:if>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>